Public Class formObject
    'Variables exposed to a caller of this form
    Public bmpObject As Bitmap
    Public intObjectIndex As Integer
    Public intObjectValue As Integer
    Public FormLeft As Integer
    Public FormTop As Integer

    Private Sub formObject_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Center the form on the screen
        Me.Height = Screen.PrimaryScreen.Bounds.Height
        Me.Left = FormLeft - Me.Width / 2
        Me.Top = 0

        'Initialize the size parameters - necessary to work with other OSs and resolutions
        picObject.Width = 32

        Select Case gintLevel
            Case 0
                picObject.Image = New Bitmap(My.Resources.Objects_Level1)
            Case 1
                picObject.Image = New Bitmap(My.Resources.Objects_Level2)
            Case 2
                picObject.Image = New Bitmap(My.Resources.Objects_Level3)
            Case 3
                picObject.Image = New Bitmap(My.Resources.Objects_Level4)
            Case 4
                picObject.Image = New Bitmap(My.Resources.Objects_Level5)
            Case Else   'Should be 5
                picObject.Image = New Bitmap(My.Resources.Objects_Level6)
        End Select

        picObject.Height = picObject.Image.Height

        If gaObjects(gintLevel).LevelObjects(intObjectIndex).SpawnAtBottom Then
            radSpawnBottom.Checked = True
        Else
            radSpawnTop.Checked = True
        End If
    End Sub

    Private Sub picObject_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picObject.MouseDown
        Dim x As Integer = e.X
        Dim y As Integer = e.Y
        Dim intIndexY As Integer

        intIndexY = Int(y / 32) 'Calculate the vertical index (each object tile is 32 pixels tall)
        'Copy the image that was clicked on (32x32).  This is available for use by the calling form
        bmpObject = ImageSubset(picObject.Image, New Rectangle(New Point(0, 0), New Point(32, 32)), New Rectangle(0, intIndexY * 32, 32, 32))
        intObjectValue = gaObjects(gintLevel).ConversionTable(intIndexY).ObjectValue    'Set the objects internal ID number.  This number is the spawn ID used by Jacakl
        Me.Close()
    End Sub

    Private Sub radSpawnTop_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radSpawnTop.CheckedChanged
        gaObjects(gintLevel).LevelObjects(intObjectIndex).SpawnAtBottom = radSpawnBottom.Checked    'Update the global internal ROM information
    End Sub

    Private Sub radSpawnBottom_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radSpawnBottom.CheckedChanged
        gaObjects(gintLevel).LevelObjects(intObjectIndex).SpawnAtBottom = radSpawnBottom.Checked    'Update the global internal ROM information
    End Sub

    Private Sub picObject_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picObject.MouseMove
        Dim intIndexY As Integer = Int(e.Y / 32)

        'Display information about each object
        If tip.GetToolTip(picObject) <> gaObjects(gintLevel).ConversionTable(intIndexY).Name Then
            tip.SetToolTip(picObject, gaObjects(gintLevel).ConversionTable(intIndexY).Name)
        End If
    End Sub
End Class